/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package action;

import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import mint.mvc.annotation.BaseMapping;
import mint.mvc.annotation.Mapping;
import mint.mvc.renderer.TemplateRenderer;

@BaseMapping("/")
public class IndexAction {

    /**
     * "/index" 和 "/"都可以访问到此方法
     *
     * @return
     */
    @Mapping(urls = {"index",""}, method = "get")
    public TemplateRenderer index(HttpServletRequest hs) {
//                    return "hollow mint-mvc";
        //System.out.println("有进来guava");
        Map<String, Object> param = new HashMap<String, Object>();
        HttpSession se = hs.getSession();
        if (se.getAttribute("username") != null) {
            param.put("state", "已登录");
            //System.out.println(se.getAttribute("username") + "guava");
            return new TemplateRenderer("/mainboard.jsp", param);
        } else {
            param.put("state", "m登录");
            //System.out.println(se.getAttribute("username") + "guava2");
            return new TemplateRenderer("/index2.jsp", param);
        }
    }
}
